home *** CD-ROM | disk | FTP | other *** search
- package com.extensibility.xa;
-
- import com.extensibility.app.BaseAction;
- import com.extensibility.app.UI;
- import com.extensibility.rock.RAction;
- import com.extensibility.rock.RBevelBorder;
- import com.extensibility.util.RuleSplitPane;
- import com.extensibility.xml.BaseDeclaration;
- import com.extensibility.xml.ElementDeclaration;
- import java.awt.Container;
- import java.awt.Dimension;
- import java.awt.GridBagConstraints;
- import java.text.MessageFormat;
- import java.util.Enumeration;
- import java.util.Vector;
- import javax.swing.JComponent;
- import javax.swing.JLabel;
- import javax.swing.JList;
- import javax.swing.JPanel;
- import javax.swing.JScrollPane;
- import javax.swing.border.Border;
- import javax.swing.event.ListSelectionEvent;
- import javax.swing.event.ListSelectionListener;
-
- public class ElementPane extends CompositePane implements ListSelectionListener {
- RuleSplitPane horizontalSplit;
- JScrollPane diagramScroller;
- JScrollPane tableScroller;
- ElementDiagram diagram = new 2(this, new ElementDiagramModel(((CompositePane)this).getSchemaDoc()));
- ElementTable table;
- JList list;
- JScrollPane listScroll;
- RuleSplitPane verticalSplit;
- JLabel listLbl;
- JPanel listPanel;
- MessageFormat listMsgFormat;
- ElementDeclaration diagramElem;
- boolean autoUpdateDiagram = true;
- BaseAction autoUpdateDiagramAction;
-
- public ElementPane(SchemaDoc var1) {
- super(var1);
- ViewportMatt var2 = new ViewportMatt(this);
- ((JComponent)var2).setBackground(this.diagram.getBackground());
- GridBagConstraints var3 = new GridBagConstraints();
- var3.anchor = 10;
- ((Container)var2).add(this.diagram, var3);
- this.diagramScroller = new JScrollPane(var2);
- this.diagramScroller.setBorder((Border)null);
- this.diagramScroller.setPreferredSize(new Dimension(20, 20));
- this.listMsgFormat = new MessageFormat(UI.getString("elem.used.by"));
- this.listLbl = new JLabel(UI.getString("element.usedby.no.selection"));
- this.listLbl.setBorder(new RBevelBorder());
- this.list = new JList();
- this.list.setBackground(UI.getColor(3));
- this.list.addListSelectionListener(new 3(this));
- this.listScroll = new JScrollPane(this.list);
- this.listScroll.setBorder((Border)null);
- this.listScroll.setColumnHeaderView(this.listLbl);
- this.verticalSplit = new RuleSplitPane(1, this.diagramScroller, this.listScroll);
- this.verticalSplit.setDividerRule(0.8);
- this.table = new ElementTable(new ElementTableModel(((CompositePane)this).getSchemaDoc()));
- if (!((CompositePane)this).getSchemaDoc().isSupported("GESTALT_EXTENDS")) {
- this.table.hideColumn(3);
- }
-
- this.table.addListSelectionListener(this);
- this.tableScroller = new JScrollPane(this.table);
- this.tableScroller.setBorder((Border)null);
- this.tableScroller.setHorizontalScrollBarPolicy(30);
- this.tableScroller.setVerticalScrollBarPolicy(22);
- this.tableScroller.setCorner("UPPER_RIGHT_CORNER", this.table.createCorner());
- this.horizontalSplit = new RuleSplitPane(0, this.verticalSplit, this.tableScroller);
- this.horizontalSplit.setDividerRule(0.4);
- this.horizontalSplit.setBorder((Border)null);
- ((CompositePane)this).getSchemaDoc().addDocumentListener(new 4(this));
- }
-
- public ElementDiagram getCurrentDiagram() {
- return this.diagram;
- }
-
- public BaseAction getZoomInAction() {
- return this.diagram.getZoomInAction();
- }
-
- public BaseAction getZoomOutAction() {
- return this.diagram.getZoomOutAction();
- }
-
- public JComponent getComponent() {
- return this.horizontalSplit;
- }
-
- public String getClassName() {
- return "com.extensibility.xa.ElementPane";
- }
-
- public boolean select(BaseDeclaration var1) {
- return this.table.select(var1);
- }
-
- public DeclTable getTableForClass(Class var1) {
- return var1 == Class.forName("com.extensibility.xml.ElementDeclaration") ? this.table : null;
- }
-
- public DeclTable getCurrentTable() {
- return this.table;
- }
-
- public boolean commitPendingEdits(boolean var1) {
- return this.table.commitPendingEdits(var1);
- }
-
- BaseAction getAutoUpdateDiagramAction() {
- if (this.autoUpdateDiagramAction == null) {
- this.autoUpdateDiagramAction = new 5(this, "view.item.auto.update");
- }
-
- this.autoUpdateDiagramAction.setSelected(this.getAutoUpdate());
- return this.autoUpdateDiagramAction;
- }
-
- protected RAction createCutAction() {
- return this.table.cutAction;
- }
-
- protected RAction createCopyAction() {
- return this.table.copyAction;
- }
-
- protected RAction createPasteAction() {
- return this.table.pasteAction;
- }
-
- protected RAction createClearAction() {
- return this.table.clearAction;
- }
-
- protected RAction createExpandAction() {
- return this.table.expandAction;
- }
-
- protected void updateUsedByList(ElementDeclaration var1) {
- Vector var2 = new Vector();
- if (var1 != null) {
- Enumeration var3 = ((CompositePane)this).getSchemaDoc().getUsedBy(var1);
-
- while(var3.hasMoreElements()) {
- var2.addElement(((ElementDeclaration)var3.nextElement()).getName());
- }
- }
-
- this.list.setListData(var2);
- this.listLbl.setText(this.listMsgFormat.format(new String[]{var1 == null ? "" : ((BaseDeclaration)var1).getName()}));
- this.list.repaint();
- }
-
- public void valueChanged(ListSelectionEvent var1) {
- if (!var1.getValueIsAdjusting()) {
- ElementDeclaration var2 = (ElementDeclaration)this.table.getSelectedDecl();
- if (this.autoUpdateDiagram || ((CompositePane)this).getSchemaDoc().getSchema().indexOf(this.diagramElem) == -1) {
- this.diagram.getModel().setRoot(var2);
- this.updateUsedByList(var2);
- this.diagramElem = var2;
- }
-
- ((CompositePane)this).declarationFocused(var2);
- this.verticalSplit.resetDividerLoc();
- }
- }
-
- public void setAutoUpdate(boolean var1) {
- this.autoUpdateDiagram = var1;
- }
-
- public boolean getAutoUpdate() {
- return this.autoUpdateDiagram;
- }
-
- public void focusDeclaration(BaseDeclaration var1) {
- if (var1 instanceof ElementDeclaration && var1 != this.table.getSelectedDecl()) {
- this.select(var1);
- }
-
- }
- }
-